<template>
  <div>
    <div>新页面</div>
    <el-button @click="handlePdf">下载</el-button>
    <el-button @click="handlePdf2">下载</el-button>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import { pdfConvert } from "@/api";
import html2pdf from "html2pdf.js";

const handlePdf = async () => {
  await pdfConvert();
};

const handlePdf2 = async () => {
  const htmlString = `
                <html>
                    <head>
                        <title>Test PDF</title>
                    </head>
                    <body>
                        <h1>Hello, World!</h1>
                        <p>This is a test PDF generated from an HTML string.</p>
                    </body>
                </html>
            `;
  const element = document.createElement("div");
  element.innerHTML = htmlString;

  html2pdf().from(element).save();
};
</script>
